/*
 ============================================================================
 Name		: CFaceGraph.h
 Author	  : lenli
 Version	 : 1.0
 Copyright   : 2008
 Description : CCFaceGraph declaration
 ============================================================================
 */

#ifndef CFACEGRAPH_H
#define CFACEGRAPH_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <ncvImage.h> //NokiacVImage

#include "GaborJet.h"
#include "Area.h"

// CLASS DECLARATION

/**
 *  CFaceGraph
 * 
 */
class CFaceGraph : public CBase
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CFaceGraph();

	/**
	 * Two-phased constructor.
	 */
	static CFaceGraph* NewL();

	/**
	 * Two-phased constructor.
	 */
	static CFaceGraph* NewLC();

	/**
	 * Load all point from file.
	 */
	void LoadFromFile(const TDesC& aFileName);
	
	/**
	 * Load graph main points from file.
	 */
	void LoadGraph(const TDesC& aFileName);
	
	/**
	 * Saves this facegraph to file.
	 */
	void SaveToFile(const TDesC& aFileName);
	
	/**
	 * Save main points (those needed to compare graphs) to file.
	 */
	void SaveGraph(const TDesC& aFileName);
	
	/**
	 * Load face border from an area.
	 */
	void LoadFaceLine(CArea *aArea);
	
	/**
	 * Checks whether this graph and aGraph are graphs from the same person.
	 * Jets are not compared in this function - use GetJetSimilarity.
	 */
	TInt IsSame(CFaceGraph *aGraph);
	
	/**
	 * Counts jets at the specified point from this image.
	 */
	void MakeJetsL(CNokiaCVImage *aImage);
	
	/**
	 * Return the specified jet:
	 * 1 - left eye jet
	 * 2 - right eye jet
	 * 3 - nose jet
	 * 4 - mouth jet
	 */
	CGaborJet* GetGaborJet(TInt aInd);
	
	/**
	 * Compares jets of this and the specified graph. ETrue is returned when
	 * the jet similarity is more than 90%.
	 */
	TReal GetJetSimilarity(CFaceGraph* aGraph);
	
	TBool Compare(CFaceGraph *aGraph);
	
	/**
	 * Functions used to draw the facefeatures on a photo.
	 */
	void DrawFace(CNokiaCVImage *aImage);
	void DrawEyes (CNokiaCVImage *aImage);
	void DrawNose (CNokiaCVImage *aImage);
	void DrawMouth (CNokiaCVImage *aImage);
	
	/**
	 * Functions used to draw the facegraph on a photo.
	 */
	void DrawFaceGraph (CNokiaCVImage *aImage);
	
	void PrintDebug();
	
private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CFaceGraph();

	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL();
	
	
	
public:
	TPoint up;
    TPoint up1_left;
    TPoint up1_right;
    TPoint up2_left;
    TPoint up2_right;
    
    TPoint left;
    TPoint right;
    
    TPoint down;
    TPoint down1_left;
    TPoint down1_right;
    TPoint down2_left;
    TPoint down2_right;
    
    TPoint nose_left;
    TPoint nose_right;

    TPoint left_eye_center;
    TPoint left_eye_up;
    TPoint left_eye_down;
    TPoint left_eye_left;
    TPoint left_eye_right;

    TPoint right_eye_center;
    TPoint right_eye_up;
    TPoint right_eye_down;
    TPoint right_eye_left;
    TPoint right_eye_right;
    
    TPoint mouth_left;
    TPoint mouth_right;
    TPoint mouth_up;
    TPoint mouth_down;
    
private:
    CGaborJet *iLeftEyeJet;
    CGaborJet *iRightEyeJet;
    CGaborJet *iNoseJet;
    CGaborJet *iMouthJet;
    

	};

#endif // CFaceGraph_H
